package servlet.admin;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import model.Page;
import service.OrdersService;

/**
 * Servlet implementation class AdminOrdersListServlet
 */
@WebServlet("/admin/orders_list")
public class orders_list_Servlet extends HttpServlet {

	private		OrdersService oService = new OrdersService();
	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	
		int status = 0;
		if (request.getParameter("status") != null) {
			
			status = Integer.parseInt(request.getParameter("status"));
		}
		request.setAttribute("status", status);
		int	pageNo  = 1;
		if(request.getParameter("pageNo") != null) {
			
			pageNo = Integer.parseInt(request.getParameter("pageNo"));
			
		}
		
		Page  p = oService.getOrdersPage(status,pageNo);
		request.setAttribute("p", p);
		request.getRequestDispatcher("/admin/orders_list.jsp").forward(request, response);
		
	}


}
